package com.beiben.quality.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.beiben.quality.mapper.QaContractSumMapper;
import com.beiben.quality.domain.QaContractSum;
import com.beiben.quality.service.IQaContractSumService;

/**
 * 合同数Service业务层处理
 *
 * @author gx
 * @date 2021-03-10
 */
@Service
public class QaContractSumServiceImpl implements IQaContractSumService
{
    @Autowired
    private QaContractSumMapper qaContractSumMapper;

    /**
     * 查询合同数
     *
     * @param contractId 合同数ID
     * @return 合同数
     */
    @Override
    public QaContractSum selectQaContractSumById(Long contractId)
    {
        return qaContractSumMapper.selectQaContractSumById(contractId);
    }

    /**
     * 查询合同数列表
     *
     * @param qaContractSum 合同数
     * @return 合同数
     */
    @Override
    public List<QaContractSum> selectQaContractSumList(QaContractSum qaContractSum)
    {
        return qaContractSumMapper.selectQaContractSumList(qaContractSum);
    }

    /**
     * 新增合同数
     *
     * @param qaContractSum 合同数
     * @return 结果
     */
    @Override
    public int insertQaContractSum(QaContractSum qaContractSum)
    {
        qaContractSum.setCreateTime(DateUtils.getNowDate());
        qaContractSum.setCreateBy(SecurityUtils.getUsername());
        qaContractSum.setDeptId(SecurityUtils.getLoginUser().getUser().getDeptId());
        qaContractSum.setDeptName(SecurityUtils.getLoginUser().getUser().getDept().getDeptName());
        return qaContractSumMapper.insertQaContractSum(qaContractSum);
    }

    /**
     * 修改合同数
     *
     * @param qaContractSum 合同数
     * @return 结果
     */
    @Override
    public int updateQaContractSum(QaContractSum qaContractSum)
    {
        qaContractSum.setUpdateTime(DateUtils.getNowDate());
        qaContractSum.setUpdateBy(SecurityUtils.getUsername());
        qaContractSum.setDeptId(SecurityUtils.getLoginUser().getUser().getDeptId());
        qaContractSum.setDeptName(SecurityUtils.getLoginUser().getUser().getDept().getDeptName());
        return qaContractSumMapper.updateQaContractSum(qaContractSum);
    }

    /**
     * 批量删除合同数
     *
     * @param contractIds 需要删除的合同数ID
     * @return 结果
     */
    @Override
    public int deleteQaContractSumByIds(Long[] contractIds)
    {
        return qaContractSumMapper.deleteQaContractSumByIds(contractIds);
    }

    /**
     * 删除合同数信息
     *
     * @param contractId 合同数ID
     * @return 结果
     */
    @Override
    public int deleteQaContractSumById(Long contractId)
    {
        return qaContractSumMapper.deleteQaContractSumById(contractId);
    }
}
